package com.dbms.controller;

import com.dbms.domain.entity.User;
import com.dbms.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "用户管理", description = "用户管理相关接口")
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {

    final UserService userService;

    @Operation(summary = "获取MySQL用户列表", description = "从MySQL数据源获取所有用户信息")
    @GetMapping("/mysql")
    public List<User> getMySQLUsers() {
        return userService.getMySQLUsers();
    }

    @Operation(summary = "获取SQLServer用户列表", description = "从SQLServer数据源获取所有用户信息")
    @GetMapping("/sqlserver")
    public List<User> getSQLServerUsers() {
        return userService.getSQLServerUsers();
    }

    @Operation(summary = "添加用户", description = "添加新用户（默认保存到MySQL）")
    @PostMapping
    public void addUser(@Parameter(description = "用户信息") @RequestBody User user) {
        userService.addUser(user);
    }
}